//当前这个模块：API进行统一管理
import requests from "./request";
import mockRequests from "./mockRequest";

//三级联动接口
//    /api/product/getBaseCategoryList
//  export const getBaseCategoryList = ()=>{
//     return requests({
//       url:'/product/getBaseCategoryList',
//       method:'get'
//    })
//  }

// 分类列表
export const getBaseCategoryList = () =>
  requests({ url: "/product/getBaseCategoryList", method: "get" });

// 轮播图
export const getBannerList = () =>
  mockRequests({ url: "/banner", method: "get" });

// floor
export const getFloorList = () =>
  mockRequests({ url: "/floor", method: "get" });

// 获取搜索 模块数据
//当前这个接口（获取搜索模块的数据），给服务器传递一个默认参数【至少是一个空对象】
export const getSearchInfo = (params) =>
  requests({ url: "/list", method: "post", data: params });

// 获取详情页数据
export const getDetailInfo = (skuId) =>
  requests({ url: `/item/${skuId}`, method: "get" });

//将产品添加到购物车中（获取更新某一个产品的个数）
///api/cart/addToCart/{ skuId }/{ skuNum }  POST
export const getAddOrUpdateShopCart = (skuId, skuNum) =>
  requests({ url: `/cart/addToCart/${skuId}/${skuNum}`, method: "post" });

//获取购物车列表数据接口
//URL:/api/cart/cartList   method:get
export const reqCartList = () =>
  requests({ url: "/cart/cartList ", method: "get" });

//删除购物产品的接口
//URL:/api/cart/deleteCart/{skuId}   method:DELETE
export const reqDeleteCartById = (skuId) =>
  requests({ url: `/cart/deleteCart/${skuId}`, method: "delete" });

//修改商品的选中状态
//URL:/api/cart/checkCart/{skuId}/{isChecked}   method:get
export const reqUpdateCheckedByid = (skuId, isChecked) =>
  requests({ url: `/cart/checkCart/${skuId}/${isChecked}`, method: "get" });
